import request from "../utils/request.js";

// 用户注册
export const usersRegisterService = (registerData) => {
    const params = new URLSearchParams()
    params.append('userName', registerData.userName)
    params.append('password', registerData.password)
    params.append('email', registerData.email)
    return request.post('/user/register', params);
}

// 用户登录
export const usersLoginService = (loginData) => {
    const params = new URLSearchParams()
    params.append('userName', loginData.userName)
    params.append('password', loginData.password)
    return request.post('auth/loginWithUsernamePassword', params);
}

// 重置密码步骤一：发送验证码
export const resetPwdStep1Service = (email) => {
    const params = new URLSearchParams()
    params.append('email', email)
    return request.post('/user/updatePwdWithEmailStepOne', params);
}

// 重置密码步骤二：验证验证码
export const resetPwdStep2Service = (data) => {
    const params = new URLSearchParams()
    params.append('email', data.email)
    params.append('code', data.code)
    console.log(params)
    return request.post('/user/updatePwdWithEmailStepTwo', params);
}

// 重置密码步骤三：更新密码
export const resetPwdStep3Service = (newPwd) => {
    const params = new URLSearchParams()
    params.append('newPwd', newPwd)
    return request.patch('/user/updatePwdWithEmailStepThree', params);
}